﻿<ResourceDictionary
     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
     xmlns:system="clr-namespace:System;assembly=mscorlib" 
     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    >

    <Style x:Key="{x:Type ToggleButton}"  TargetType="{x:Type ToggleButton}">
        <Setter Property="SnapsToDevicePixels" Value="True"/>
        <Setter Property="BorderThickness" Value="1" />
        <Setter Property="Foreground" Value="{DynamicResource ForegroundBrush_Button}" />
        <Setter Property="FontFamily" Value="SimSun" />
        <Setter Property="FontSize" Value="13" />
        <Setter Property="HorizontalContentAlignment" Value="Center" />
        <Setter Property="VerticalContentAlignment" Value="Center" />
        <Setter Property="Padding" Value="5" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ToggleButton}">
                    <ControlTemplate.Resources>
                        <Storyboard x:Key="HoverOn">
                            <DoubleAnimation Duration="00:00:00.1000000" Storyboard.TargetName="BackgroundOver" Storyboard.TargetProperty="Opacity" To="1" />
                            <DoubleAnimation Duration="00:00:00.1000000" Storyboard.TargetName="BackgroundOver_Highlight" Storyboard.TargetProperty="Opacity" To="1" />

                        </Storyboard>
                        <Storyboard x:Key="HoverOff">
                            <DoubleAnimation Duration="00:00:00.4000000" Storyboard.TargetName="BackgroundOver" Storyboard.TargetProperty="Opacity" To="0" />
                            <DoubleAnimation Duration="00:00:00.4000000" Storyboard.TargetName="BackgroundOver_Highlight" Storyboard.TargetProperty="Opacity" To="0" />

                        </Storyboard>
                        <Storyboard x:Key="CheckedOn">
                            <DoubleAnimation Duration="00:00:00.1000000" Storyboard.TargetName="BackgroundChecked" Storyboard.TargetProperty="Opacity" To="0.84" />
                            <DoubleAnimation Duration="00:00:00.1000000" Storyboard.TargetName="BackgoundChecked_Highlight" Storyboard.TargetProperty="Opacity" To="1" />
                            <DoubleAnimation Duration="00:00:00.1000000" Storyboard.TargetName="BackgroundPressedShadow" Storyboard.TargetProperty="Opacity" To="0.84" />
                            <DoubleAnimation Duration="00:00:00.1000000" Storyboard.TargetName="BackgroundPressedInnerShadow" Storyboard.TargetProperty="Opacity" To="1.0" />
                        </Storyboard>
                        <Storyboard x:Key="CheckedOff">
                            <DoubleAnimation Duration="00:00:00.4000000" Storyboard.TargetName="BackgroundChecked" Storyboard.TargetProperty="Opacity" To="0" />
                            <DoubleAnimation Duration="00:00:00.4000000" Storyboard.TargetName="BackgoundChecked_Highlight" Storyboard.TargetProperty="Opacity" To="0" />
                            <DoubleAnimation Duration="00:00:00.4000000" Storyboard.TargetName="BackgroundPressedShadow" Storyboard.TargetProperty="Opacity" To="0.0" />
                            <DoubleAnimation Duration="00:00:00.4000000" Storyboard.TargetName="BackgroundPressedInnerShadow" Storyboard.TargetProperty="Opacity" To="0.0" />
                        </Storyboard>

                        <Storyboard x:Key="PressedOn">
                            <DoubleAnimation Duration="00:00:00.0010000" Storyboard.TargetName="BackgroundPressed" Storyboard.TargetProperty="Opacity" To="0.84" />
                            <DoubleAnimation Duration="00:00:00.0010000" Storyboard.TargetName="BackgoundPressed_Highlight" Storyboard.TargetProperty="Opacity" To="1" />
                            <DoubleAnimation Duration="00:00:00.1000000" Storyboard.TargetName="BackgroundPressedShadow" Storyboard.TargetProperty="Opacity" To="0.84" />
                            <DoubleAnimation Duration="00:00:00.1000000" Storyboard.TargetName="BackgroundPressedInnerShadow" Storyboard.TargetProperty="Opacity" To="1.0" />
                        </Storyboard>
                        <Storyboard x:Key="PressedOff">
                            <DoubleAnimation Duration="00:00:00.0010000" Storyboard.TargetName="BackgroundPressed" Storyboard.TargetProperty="Opacity" To="0" />
                            <DoubleAnimation Duration="00:00:00.0010000" Storyboard.TargetName="BackgoundPressed_Highlight" Storyboard.TargetProperty="Opacity" To="0" />
                            <DoubleAnimation Duration="00:00:00.0010000" Storyboard.TargetName="BackgroundPressedShadow" Storyboard.TargetProperty="Opacity" To="0.0" />
                            <DoubleAnimation Duration="00:00:00.0010000" Storyboard.TargetName="BackgroundPressedInnerShadow" Storyboard.TargetProperty="Opacity" To="0.0" />
                        </Storyboard>
                        <Storyboard x:Key="FocusedOn">
                            <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="FocusVisualElement" Storyboard.TargetProperty="(UIElement.Opacity)">
                                <SplineDoubleKeyFrame KeyTime="00:00:00.1000000" Value="1" />
                            </DoubleAnimationUsingKeyFrames>
                        </Storyboard>
                        <Storyboard x:Key="FocusedOff">
                            <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="FocusVisualElement" Storyboard.TargetProperty="(UIElement.Opacity)">
                                <SplineDoubleKeyFrame KeyTime="00:00:00.3000000" Value="0" />
                            </DoubleAnimationUsingKeyFrames>
                        </Storyboard>

                    </ControlTemplate.Resources>
                    <Grid  SnapsToDevicePixels="True" UseLayoutRounding="True" x:Name="grid1">
                        <Border x:Name="BackgroundNorm" BorderThickness="1" CornerRadius="1.75" Background="{DynamicResource NormalBrush_Button}" BorderBrush="{DynamicResource NormalBorderBrush_Button}"/>
                        <Border x:Name="BackgroundNorm_highlight" Margin="1" BorderBrush="{DynamicResource NormalHighlightBrush_Button}" BorderThickness="1,1,1,1" CornerRadius="1" Opacity="0.65" />
                        <Border x:Name="BackgroundChecked" BorderThickness="1" CornerRadius="1.75" Opacity="0" Background="{DynamicResource PressedBrush_Button}" BorderBrush="{DynamicResource PressedBorderBrush_Button}"/>
                        <Border x:Name="BackgoundChecked_Highlight" Margin="1" BorderThickness="1" CornerRadius="1" Opacity="0" BorderBrush="{DynamicResource PressedHighlightBrush_Button}"/>
                        <Border x:Name="BackgroundOver" BorderThickness="1" CornerRadius="1.75" Opacity="0" Background="{DynamicResource MouseOverBrush_Button}" BorderBrush="{DynamicResource MouseOverBorderBrush_Button}"/>
                        <Border x:Name="BackgroundOver_Highlight" Margin="1" BorderThickness="1,1,1,1" CornerRadius="1" Opacity="0" BorderBrush="{DynamicResource MouseOverHighlightBrush_Button}"/>
                        <Border x:Name="BackgroundPressed" BorderThickness="1" CornerRadius="1.75" Opacity="0" Background="{DynamicResource PressedBrush_Button}" BorderBrush="{DynamicResource PressedBorderBrush_Button}"/>
                        <Border x:Name="BackgoundPressed_Highlight" Margin="1" BorderThickness="1,1,1,1" CornerRadius="1" Opacity="0" BorderBrush="{DynamicResource PressedHighlightBrush_Button}"/>
                        <Border x:Name="BackgroundPressedShadow" Margin="1" BorderThickness="1" CornerRadius="1.75" Opacity="0" Background="Transparent" BorderBrush="{DynamicResource PressedShadowBorderBrush_Button}"/>
                        <Border x:Name="BackgroundPressedInnerShadow" Margin="2" BorderThickness="1" CornerRadius="1.75" Opacity="0" Background="Transparent" BorderBrush="{DynamicResource PressedInnerShadowBorderBrush_Button}"/>
                        <Border x:Name="DisabledVisualElement" IsHitTestVisible="false" Background="{DynamicResource DisabledBackgroundBrush_Button}" BorderBrush="{DynamicResource DisabledBorderBrush_Button}" BorderThickness="1" Opacity="0" />
                        <ContentPresenter x:Name="contentPresenter" Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" />
                        <TextBlock Panel.ZIndex="1" x:Name="DisabledOverlay" Text="{TemplateBinding Content}" Foreground="#FF8E96A2" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Margin="{TemplateBinding Padding}" Visibility="Collapsed" />
                        <Border x:Name="FocusVisualElement" Margin="-1" Grid.RowSpan="2" BorderBrush="{DynamicResource ButtonFocusBrush}" BorderThickness="1" CornerRadius="2.75" IsHitTestVisible="false" Opacity="0" />
                    </Grid>

                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Trigger.ExitActions>
                                <BeginStoryboard Storyboard="{StaticResource HoverOff}" x:Name="HoverOff_BeginStoryboard" />
                            </Trigger.ExitActions>
                            <Trigger.EnterActions>
                                <BeginStoryboard Storyboard="{StaticResource HoverOn}" x:Name="HoverOn_BeginStoryboard"/>
                            </Trigger.EnterActions>
                            <Setter Property="Foreground" Value="Black" />
                        </Trigger>
                        <Trigger Property="IsPressed" Value="True">
                            <Trigger.ExitActions>
                                <BeginStoryboard Storyboard="{StaticResource PressedOff}" x:Name="PressedOff_BeginStoryboard" />
                            </Trigger.ExitActions>
                            <Trigger.EnterActions>
                                <BeginStoryboard Storyboard="{StaticResource PressedOn}" x:Name="PressedOn_BeginStoryboard" />
                            </Trigger.EnterActions>
                            <Setter Property="Foreground" Value="Black" />

                        </Trigger>
                        <Trigger Property="IsKeyboardFocused" Value="true">
                            <Trigger.ExitActions>
                                <BeginStoryboard Storyboard="{StaticResource FocusedOff}" x:Name="FocusedOff_BeginStoryboard" />
                            </Trigger.ExitActions>
                            <Trigger.EnterActions>
                                <BeginStoryboard Storyboard="{StaticResource FocusedOn}" x:Name="FocusedOn_BeginStoryboard" />
                            </Trigger.EnterActions>
                        </Trigger>
                        <Trigger Property="IsChecked" Value="true">
                            <Trigger.ExitActions>
                                <BeginStoryboard Storyboard="{StaticResource CheckedOff}" x:Name="CheckedOff_BeginStoryboard" />
                            </Trigger.ExitActions>
                            <Trigger.EnterActions>
                                <BeginStoryboard Storyboard="{StaticResource CheckedOn}" x:Name="CheckedOn_BeginStoryboard" />
                            </Trigger.EnterActions>
                            <Setter Property="Foreground" Value="Black" />

                        </Trigger>
                        <Trigger Property="IsEnabled" Value="false">
                            <Setter Property="Foreground" Value="{DynamicResource DisabledForegroundBrush_Button}" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <Style x:Key="ToggleButton_Default" TargetType="ToggleButton" BasedOn="{StaticResource {x:Type ToggleButton}}"/>
</ResourceDictionary>
